import printCanvas from './printCanvas'

const redrawCanvas = function (canvas, filter) {
  // 采用此方法获取实际宽高是因为OpenHarmony不支持element.width此类方法，需注意此方法会有bug
  let rect = canvas.getBoundingClientRect()
  let ctx = canvas.getContext('2d')
  let args = [ctx.getImageData(0, 0, rect.width, rect.height)]

  return printCanvas(canvas, filter.apply(null, args))
}

export default redrawCanvas
